package com.hongji.lms5xxcommunicator.scanner;

import com.hongji.lms5xxcommunicator.scanner.imp.LivoxMid360ScannerStrategy;
import com.hongji.lms5xxcommunicator.scanner.imp.Lms5xxScannerStrategy;
import com.hongji.lms5xxcommunicator.scanner.imp.MultiLivoxScannerStrategy;
import com.hongji.lms5xxcommunicator.scanner.imp.Pics150ScannerStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ScanStrategyFactory {

    @Value("${scanner.type}")
    private String type;

    @Autowired
    private Lms5xxScannerStrategy lms;

    @Autowired
    private Pics150ScannerStrategy pics;

    @Autowired
    private LivoxMid360ScannerStrategy livox;

    @Autowired
    private MultiLivoxScannerStrategy multiLivox;

    public ScanStrategy resolve() {
        if ("PICS150".equalsIgnoreCase(type)) {
            return pics;
        } else if ("LMS511".equalsIgnoreCase(type)) {
            return lms;
        } else if ("Livox360".equalsIgnoreCase(type)) {
            return livox;
        } else if ("Livox360Multi".equalsIgnoreCase(type)) {
            return multiLivox;
        } else {
            log.info("未找到配置项中对应的扫描仪，请确认配置项中scanner.type是否是现有扫描仪类型{PICS150/LMS511/Livox360}！");
            return null;
        }
    }
}
